package com.mod;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author jianxy
 * @date 2025-08-19 22:26
 */
@RestController
@RequestMapping("/api")
public class DataController {
    @Autowired
    private ModbusService modbusService;

    @GetMapping("/read/{a}/{b}")
    public Number readSingleRegister(@PathVariable Integer a, @PathVariable Integer b) {
        return modbusService.readHoldingRegister(a, b); // 从站ID=1, 偏移地址0
    }
}
